VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmSelectType 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Select type"
   ClientHeight    =   5055
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   10155
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   5055
   ScaleWidth      =   10155
   Begin MSComctlLib.ListView ListView1 
      Height          =   4455
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   10095
      _ExtentX        =   17806
      _ExtentY        =   7858
      View            =   3
      Arrange         =   2
      LabelEdit       =   1
      Sorted          =   -1  'True
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      FullRowSelect   =   -1  'True
      GridLines       =   -1  'True
      _Version        =   393217
      ColHdrIcons     =   "ImageList1"
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      BorderStyle     =   1
      Appearance      =   1
      NumItems        =   3
      BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Text            =   "Item"
         Object.Width           =   4304
      EndProperty
      BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   1
         Text            =   "Type Description"
         Object.Width           =   7056
      EndProperty
      BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   2
         Text            =   "Type For"
         Object.Width           =   2540
      EndProperty
   End
   Begin VB.TextBox txtItem 
      Height          =   375
      Left            =   1800
      TabIndex        =   4
      Top             =   3960
      Width           =   2175
   End
   Begin VB.TextBox txtSelect 
      Height          =   495
      Left            =   3120
      TabIndex        =   3
      Top             =   5760
      Width           =   1215
   End
   Begin MSComctlLib.ImageList ImageList1 
      Left            =   5640
      Top             =   2760
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   17
      ImageHeight     =   17
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   3
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmSelectType.frx":0000
            Key             =   ""
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmSelectType.frx":21DD
            Key             =   ""
         EndProperty
         BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmSelectType.frx":3940
            Key             =   ""
         EndProperty
      EndProperty
   End
   Begin VB.PictureBox Picture1 
      Appearance      =   0  'Flat
      AutoSize        =   -1  'True
      BackColor       =   &H80000005&
      BorderStyle     =   0  'None
      ForeColor       =   &H80000008&
      Height          =   225
      Left            =   9600
      Picture         =   "frmSelectType.frx":3BD8
      ScaleHeight     =   225
      ScaleWidth      =   240
      TabIndex        =   2
      ToolTipText     =   "Help.."
      Top             =   120
      Width           =   240
   End
   Begin VB.CommandButton Command4 
      Caption         =   "&Select this one .."
      Height          =   375
      Left            =   8400
      TabIndex        =   1
      Top             =   4560
      Width           =   1575
   End
End
Attribute VB_Name = "frmSelectType"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public BilltypeParameter As String
Public isSelect As Boolean
Dim formShow As Boolean
Private Sub cboOffice_Click()
SetSelecttextBox
End Sub

Private Sub cboYear_Click()
SetSelecttextBox
End Sub

Private Sub Command1_Click()
Dim sql As String
Dim rs As New ADODB.Recordset
Dim bill As String
Dim i, N As Integer
If Trim(txtType.Text) = "" Or Trim(txtDes.Text) = "" Then
    MsgBox "The Type and Desciption box can not be empty", vbInformation + vbOKOnly, "Message"
    Exit Sub
    
End If
If MsgBox("Do you want to add this Type (Y/N)", vbQuestion + vbYesNo + vbDefaultButton2, "Message") = vbNo Then
    Exit Sub
End If
For i = 0 To optType.Count - 1
    If optType(i).Value = True Then
        N = i
    End If
Next i
Select Case N
    Case 0
        bill = "RC"
    Case 1
        bill = "IV"
    Case 2
        bill = "ME"
    Case 3
        bill = "BF"
    Case 4
        bill = "TI"
End Select
sql = "select * from typelist where name ='" & txtType.Text & "' and bill='" & bill & "'"
Set rs = adoConnection.Execute(sql)
If Not rs.EOF Then
    MsgBox "This type already exists"
    txtType.SetFocus
    rs.Close
    Set rs = Nothing
    Exit Sub
End If
rs.Close
    Set rs = Nothing
sql = "insert into typelist(name,DES,bill) values('" & txtType.Text & "','" & txtDes.Text & "','" & bill & "')"
adoConnection.Execute (sql)
txtType.Text = ""
txtDes.Text = ""
Call displayUser
MsgBox "Save successfully", vbInformation + vbOKOnly, "Message"
'Call SetTypeValue(frmIncoice.cboType, BilltypeParameter)
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Command3_Click()
Dim sql As String
Dim i As Integer
If ListView1.ListItems.Count <= 0 Then
    Exit Sub
End If


 
If Trim(ListView1.SelectedItem.Text) <> "" Then
    If MsgBox("Do you want to delete this item?(Y/N)", vbQuestion + vbYesNo + vbDefaultButton2, "Question") = vbNo Then
        Exit Sub
    End If
    sql = "Delete from typelist where name ='" & ListView1.SelectedItem.Text & "'"
    adoConnection.Execute (sql)
    displayUser
    
Else
    MsgBox "You must select atleast one item", vbInformation + vbOKOnly, "Message"
End If
'Call SetTypeValue(frmIncoice.cboType, BilltypeParameter)
End Sub

Private Sub Command4_Click()
If isSelect Then
If BilltypeParameter = "ESTIMATED" Then
    frmEstimatedExp.cboType.Text = txtSelect.Text
    frmEstimatedExp.lblItem.Caption = txtItem.Text
Else
    frmIncoice.cboType.Text = txtSelect.Text
End If
Unload Me
End If
End Sub

Private Sub Command5_Click()
If formShow Then
Me.Height = 7515
formShow = False
Command5.Enabled = True
Else
formShow = True
Me.Height = 8730
Command5.Enabled = False
End If
End Sub

Private Sub Command6_Click()
Command5.Enabled = True
formShow = False
Me.Height = 7515
End Sub

Private Sub Form_Load()
Dim rs As New ADODB.Recordset
Dim sql As String
formShow = False
'Me.Height = 7515
Me.Top = Screen.Height / 2 - (Me.Height / 1.6)
    Me.Left = Screen.Width / 2 - (Me.Width / 2)

displayUser

End Sub

Public Function displayUser()
        Dim rs As ADODB.Recordset
        Dim sql As String
        Dim item
        Set rs = New ADODB.Recordset
        
       
        sql = "Select * from typelist where bill ='IV' order by 1"
        
        Set rs = adoConnection.Execute(sql)
        ListView1.ListItems.Clear
        Do While rs.EOF = False
            Set item = ListView1.ListItems.Add(, , rs!Name)
            item.SubItems(1) = rs!Des
            item.SubItems(2) = GetBillTypeDescription(rs!bill)
            
            If rs!Name = ItemRemember Then
            item.Selected = True
            
            End If
            rs.MoveNext
        Loop
        rs.Close
        Set rs = Nothing
        ListView1.ColumnHeaders(1).Icon = 2
End Function
Private Function SetSelecttextBox()


txtSelect.Text = ListView1.SelectedItem.Text
ItemRemember = ListView1.SelectedItem.Text
txtItem.Text = ListView1.SelectedItem.SubItems(1)
If Len(txtSelect.Text) > 0 Then
    Command4.Enabled = True
Else
    Command4.Enabled = False
End If
End Function

Private Sub ListView1_Click()
SetSelecttextBox
End Sub

 

Private Sub ListView1_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
With ListView1
   ListView1.SortKey = ColumnHeader.Index - 1
    If ListView1.SortOrder = lvwAscending Then
        ListView1.SortOrder = lvwDescending
        .ColumnHeaders(1).Icon = 3
        .ColumnHeaders(2).Icon = 3
        .ColumnHeaders(3).Icon = 3
        ColumnHeader.Icon = 1
    Else
        ListView1.SortOrder = lvwAscending
        .ColumnHeaders(1).Icon = 3
        .ColumnHeaders(2).Icon = 3
        .ColumnHeaders(3).Icon = 3
        ColumnHeader.Icon = 2
    End If
    ListView1.Sorted = True
    
    
End With
End Sub
 

Private Sub ListView1_DblClick()
SetSelecttextBox
Call Command4_Click
End Sub

Private Sub ListView1_KeyUp(KeyCode As Integer, Shift As Integer)
SetSelecttextBox
End Sub

Private Sub optF_Click()
SetSelecttextBox
End Sub

Private Sub Option1_Click()
displayUser
End Sub

Private Sub Option2_Click()
displayUser
End Sub

Private Sub Option5_Click()
displayUser
End Sub

Private Sub optS_Click()
SetSelecttextBox
End Sub

